<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<probiz:pageHeading entityName="${contentRelatedType.contentRelatedTypeName}" entityHeadingKey="contentRelatedTypeDetail.heading" />

<content tag="buttons">
<probiz:iconBtn btnType="save" onclick="return fnDoSave();" />
<probiz:iconBtn btnType="back"	onclick="return fnDoCancelForm(this);" />
</content>
<probiz:showBindErrors bindPath="contentRelatedType.*" />

<form:form method="post" cssClass="mainForm" id="contentRelatedTypeForm"  name="contentRelatedTypeForm" commandName="contentRelatedType"
			action="${ctxPath}/content/contentRelatedType.html" onsubmit="return validateContentRelatedType(this);">
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr"><span><fmt:message key="contentRelatedTypeDetail.heading"/></span></li>
		</ul>
	</div>
	<div class="modify">
		<table class="com_modi_table" cellSpacing=0 cellPadding=0	width="100%" border=0>
			<tr>
				<input type="hidden" name="contentRelatedTypeId"	id="contentRelatedTypeId"	value="${contentRelatedType.contentRelatedTypeId}" />
				<th class="label_width_1">
					<StoreAdmin:label key="contentRelatedType.relatedTitle" />
				</th>
				<td>
					<span><input type="text" id="relatedTitle" name="relatedTitle"	value="${contentRelatedType.relatedTitle}" class="inputtxt" style="width:350px;"/></span>
				</td>
			</tr>	
			<tr>
				<th>
					<label for="checkbox_status"><fmt:message key="status.active" /></label>:
				</th>
				<td>
					<input type="checkbox" name="checkbox_status"
						id="checkbox_status"
						onclick="ChangeValueOfStatus(this,'status')"
						<c:if test="${contentRelatedType.status == 1}">checked</c:if>
						<c:if test="${contentRelatedType.contentRelatedTypeId == null}">checked</c:if> />
		
					<c:choose>
						<c:when test="${contentRelatedType.contentRelatedTypeId == null}">
							<input type="hidden" name="status" id="status" value="1" />
						</c:when>
						<c:otherwise>
							<form:hidden path="status" />
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
			<tr>
				<th>
					<label for="checkbox_autoEval">
						<fmt:message key="contentRelatedType.autoEval" />:
					</label>
				</th>
				<td>		
					<c:choose>
						<c:when test="${contentRelatedType.autoEval != 2}">
							<input type="checkbox" name="checkbox_autoEval"
								id="checkbox_autoEval"
								onclick="ChangeValueOfAutoEval(this,'autoEval')"
								<c:if test="${contentRelatedType.autoEval == 1}">checked</c:if>
								<c:if test="${contentRelatedType.autoEval == null}">checked</c:if> />
						</c:when>
						<c:otherwise>
							<fmt:message key="contentRelatedType.autoEval.s2"/>
						</c:otherwise>
					</c:choose>
					<c:choose>
						<c:when test="${contentRelatedType.contentRelatedTypeId == null}">
							<input type="hidden" name="autoEval" id="autoEval" value="1" />
						</c:when>
						<c:otherwise>
							<form:hidden path="autoEval" />
						</c:otherwise>
					</c:choose>
					
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="contentRelatedType.typeName" />
				</th>
				<td>
					<span><input type="text" id="typeName" name="typeName"	value="${contentRelatedType.typeName}" readonly="true"  style="width:150px;"/></span>
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="contentRelatedType.ruleCode" />
				</th>
				<td>
					<fmt:message key="contentRelatedType.ruleCode${contentRelatedType.ruleCode}" />
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="contentRelatedType.position" />
				</th>
				<td>
					<c:choose>
						<c:when test="${contentRelatedType.isApplyToContent == 1 and contentRelatedType.isApplyToCategory == 0}">
							<fmt:message key="contentRelatedType.position.content"/>
						</c:when>
						<c:when test="${contentRelatedType.isApplyToContent == 0 and contentRelatedType.isApplyToCategory == 1}">
							<fmt:message key="contentRelatedType.position.category"/>
						</c:when>
					</c:choose>
				</td>
			</tr>
		
		</table>
	</div>
</form:form>

<v:javascript formName="contentRelatedType" staticJavascript="false" />
<script type="text/javascript">
document.forms["contentRelatedTypeForm"].elements["relatedTitle"].focus();
 
function ChangeValueOfStatus(checkbox,persistInput)
{
    if (checkbox.checked==true)
    {
      	$(persistInput).value = 1;
    }
    else
    {
      	$(persistInput).value = 0;
    }
}

function ChangeValueOfAutoEval(checkbox,persistInput)
{
    if (checkbox.checked==true)
    {
      	$(persistInput).value = 1;
    }
    else
    {
      	$(persistInput).value = 0;
    }
}

function validateAction(){
	 if(!validateContentRelatedType()){
    	return false;
   	}
   	   
    return true;
}

function fnDoSave(){
	var confirmMsg = __FMT.common_message_confirmSaveThis+"?";
	if(validateAction()){
    	if (!confirmMsg || confirm(confirmMsg)) {
	    	document.contentRelatedTypeForm.action += "?doAction=save";
			document.contentRelatedTypeForm.submit();
	    }
    }
}   
</script>
